QuickOPC User's Guide and Reference
Use generic or type-safe access wherever possible
Best Practices > Use generic or type-safe access wherever possible

OPC “Classic” represents data using OLE Automation VARIANT-s, which are transformed to .NET (CLR) objects. As such, a value of any type can appear in place of OPC data. Your code typically knows that certain piece of data (such as OPC item) is of specific type (such as 32-bit signed integer), and expects that the value indeed is of this type.

Instead of trying to put the type conversions and safety checks in your code, you should use the features already available in QuickOPC.NET.

If your language supports generics and you feel comfortable working with them, it is the best choice to use generic types and generic access (see e.g. Generic Types and Generic Access). The second best choice is type-safe access, which provides similar functionality, but without use of generics (see e.g. Type-safe Access).

See Also